package com.example.yinzradio.project;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;

@Controller
public class AudioPlay {

    String filePath = "D:\\work\\报告\\系统\\印字班\\语音包\\工艺调试呼叫语音包\\4号印字机工艺调试.wav";

    @GetMapping("/play")
    @ResponseBody
    public void play(String path){

        File file = new File(filePath);
        try{
            AudioClip audioClip = Applet.newAudioClip(file.toURI().toURL());
            audioClip.play();
        }
        catch ( Exception e){
            e.printStackTrace();
        }
    }
}
